import React, { Fragment, useState, useEffect } from 'react';
import type { FC } from 'react';
import { Calendar, Badge, Drawer, Form, Input, Checkbox, Button, Select, message } from 'antd';
import style from './index.less';
import { Link, useHistory } from 'umi';
import { getAddress} from './service';

const Choose: FC<Record<string, any>> = () => {

//请求接口
const addColumn = async(value: any)=>{
  const {code} = await getAddress({name:value.name,phone:value.phone,province:value.province,area:value.area,address:value.address,city:value.city,})
  code === 1000 ? message.success('礼物兑换申请成功') : message.error('礼物兑换申请失败')
}

  //确认收货地址
  const onFinish = (values: any) => {
    console.log('Success:', values);
    addColumn(values)
  };
  const onFinishFailed = (errorInfo: any) => {
  };
  const { Option } = Select;
  return (
    <div className={style.content}>
          <div className={style.cal}>
            <div className={style.title} style={{fontSize:'25px',fontWeight:"bold",margin:'20px 10px'}}>请填写收货信息</div>
              <Form
                name="basic"
                labelCol={{ span: 8 }}
                wrapperCol={{ span: 14 }}
                initialValues={{ remember: true }}
                onFinish={onFinish}
                onFinishFailed={onFinishFailed}
                autoComplete="off"
            >
              <Form.Item
                label="收货人姓名"
                name="name"
                rules={[{ required: true, message: '请输入收货人姓名！' }]}
              >
                <Input />
              </Form.Item>
              <Form.Item
                label="收货人电话"
                name="phone"
                rules={[{ required: true, message: '请输入收货人联系电话！' }]}
              >
                <Input />
              </Form.Item>
              <Form.Item
                label="收货省"
                name="province"
                rules={[{ required: true, message: '请输入收货省！' }]}
              >
                <Input />
              </Form.Item>
              <Form.Item
                label="收货市"
                name="city"
                rules={[{ required: true, message: '请输入收货市！' }]}
              >
                <Input />
              </Form.Item>
              <Form.Item
                label="收货区"
                name="area"
                rules={[{ required: true, message: '请输入收货区！' }]}
              >
                <Input />
              </Form.Item>
              <Form.Item
                label="详细住址"
                name="address"
                rules={[{ required: true, message: '请输入详细地址！' }]}
              >
                <Input />
              </Form.Item>


              <Form.Item wrapperCol={{ offset: 8, span: 16 }}>
                <Button type="primary" htmlType="submit">
                  提交信息
                </Button>
              </Form.Item>
            </Form>

          </div>
    </div>


  );
};
export default Choose;
